#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 1e5+10;
int n,m;
int a[N];
int dp[N];
int main() {
    int ma=0;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    ma=max(a[1],a[2]);
    dp[2]=min(a[1],a[2]);
    for(int i=3;i<=n;i++)
    {
        if(a[i]<=dp[i-1]){
            dp[i]=dp[i-1];
            ma=max(ma,a[i]);
        }else{
            dp[i]=min(a[i],ma);
            ma=max(ma,a[i]);
        }
    }
    cin >> m;
    while(m--)
    {
        int x;
        cin >> x;
        cout << dp[x] << endl;
    }
    return 0;
}